#!/bin/bash

APP_BIN_NAME=$1
USER_SW_VER=$2

ABS_PATH=$(pwd)

export SDK_PATH=${ABS_PATH%/*}
export BIN_PATH=$ABS_PATH/$APP_BIN_NAME/bin

echo ""
echo "start..."
echo ""
cd $APP_BIN_NAME

make clean
make BOOT=new APP=1 SPI_SPEED=40 SPI_MODE=QIO SPI_SIZE_MAP=2 APP_BIN_NAME=$APP_BIN_NAME USER_SW_VER=$USER_SW_VER ENABLE_8266TLS=$enable8266tls
echo "chmod 777 -R $BIN_PATH/"
sudo chmod 777 -R $BIN_PATH/

# echo ""
# echo "start..."
# echo ""
# set -e
# make -C ./package clean
# make -C ./package install INSALL=../../bin/upgrade USER_SW_VER=$USER_SW_VER

# make clean APP_BIN_NAME=$APP_BIN_NAME;\
# make COMPILE=gcc BOOT=new APP=1 SPI_SPEED=40 SPI_MODE=QIO SPI_SIZE_MAP=2 APP_BIN_NAME=$APP_BIN_NAME USER_SW_VER=$USER_SW_VER ENABLE_8266TLS=$enable8266tls
# make clean APP_BIN_NAME=$APP_BIN_NAME;\
# make COMPILE=gcc BOOT=new APP=2 SPI_SPEED=40 SPI_MODE=QIO SPI_SIZE_MAP=2 APP_BIN_NAME=$APP_BIN_NAME USER_SW_VER=$USER_SW_VER ENABLE_8266TLS=$enable8266tls

